package com.itheima.stock.controller;

import com.itheima.stock.annotation.Limiter;
import com.itheima.stock.api.UserControllerAPI;
import com.itheima.stock.dto.LoginDto;
import com.itheima.stock.response.ResponseResult;
import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.CaptchaVo;
import com.itheima.stock.vo.InnerMarketVO;
import com.itheima.stock.vo.LoginVo;
import com.itheima.stock.vo.MarketIndexVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zby
 * @created 2024-06-22 22:48
 * @description 用户接口实现
 */
@RestController
@Slf4j
public class UserController implements UserControllerAPI {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }


    @Override
    public String getName(String name) {
        return name;
    }

    @Override
    @Limiter
    public ResponseResult<CaptchaVo> getCaptcha() {
        return ResponseResult.ok(userService.getCaptcha());
    }

    @Override
    public ResponseResult<LoginVo> login(LoginDto loginDto) {
        log.info("{}",loginDto);
        return ResponseResult.ok(userService.login(loginDto));
    }


}
